package com.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.entity.StudentSign;
import com.example.mapper.StudentSignMapper;
import com.example.service.StudentSignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

//实现StudentSignService接口
@Service
public class StudentSignImpl extends ServiceImpl<StudentSignMapper, StudentSign> implements StudentSignService {
    @Autowired
    private StudentSignMapper studentSignMapper;

    //    根据传入的sign-id查询签到记录并返回
    @Override
    public StudentSign getInfoBySignIdAndAccount(String sign, String account) {
//        根据传入的sign-id，和学号查询签到记录，返回多条已经签到的记录

        List<StudentSign> studentSignList = this.lambdaQuery().eq(StudentSign::getSignId, sign).eq(StudentSign::getAccount, account)
                .select(StudentSign::getAccount, StudentSign::getUserName).list();
        if (studentSignList.size() == 0) {
            return null;
        }
        return studentSignList.get(0);
    }
}
